package tech.edwardvan.java.methodreference;

import lombok.extern.slf4j.Slf4j;

import java.util.function.Consumer;

/**
 * 方法引用
 * <p>
 * 引用特定对象的实例方法。例如：instance::method
 *
 * @author EdwardVan
 */
@Slf4j
public class MethodReferenceDemo4 {

    private static void invoke(Consumer<String> consumer) {
        consumer.accept("EdwardVan");
    }

    public void showName(String name) {
        log.info("My name is {}", name);
    }

    public static void main(String[] args) {
        MethodReferenceDemo4 test = new MethodReferenceDemo4();
        /*
        class 匿名类 implements Consumer<String>{
            public void accept(String name) {
                test.showName(name);
            }
        }
         */
        invoke(test::showName);
    }


}
